package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.dto.GoodsSalesDTO;
import com.sky.dto.OrdersDTO;
import com.sky.dto.OrdersPageQueryDTO;
import com.sky.entity.Orders;
import com.sky.vo.OrderVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.time.LocalDateTime;
import java.util.List;

@Mapper
public interface OrderMapper {

    void insertOrder(@Param("order") Orders order);

    /**
     * 根据用户id查询全部订单
     * @param ordersPageQueryDTO
     * @return
     */
    Page<OrderVO> queryOrder(@Param("orderDTO")OrdersPageQueryDTO ordersPageQueryDTO);

    /**
     * 根据订单id查询订单
     * @param id
     * @return
     */
    OrderVO selectOrderById(@Param("orderId") Long id);

    /**
     * 取消订单
     * @param orders
     */
    void updateOrderStatus(@Param("orders") Orders orders);

    /**
     * 根据状态查数量
     * @param confirmed
     * @return
     */
    Integer statusCount(Integer confirmed);


    Integer getStatusById(@Param("id") Long id);

    List<Long> getOrderByStatusAndTime(@Param("status") Integer pendingPayment,@Param("minusTime") LocalDateTime minusMinutes);

    /**
     * 超时订单状态修改
     * @param orders
     * @param ordersId
     */
    void updateOrder(@Param("orders") Orders orders, @Param("orderIds") List<Long> ordersId);

    /**
     * 一天里所有的已完成的订单的营业额总数
     * @param beginTime
     * @param endTime
     * @param completed
     * @return
     */
    Double getAmountByDateAndStatus(@Param("begin") LocalDateTime beginTime,@Param("end") LocalDateTime endTime,@Param("status") Integer completed);

    /**
     * 获取订单数量
     * @param beginTime
     * @param endTime
     * @param status
     * @return
     */
    Integer getOrderCount(@Param("begin") LocalDateTime beginTime,@Param("end") LocalDateTime endTime,@Param("status") Integer status);

    List<GoodsSalesDTO> getTop10(@Param("begin")LocalDateTime beginTime,@Param("end") LocalDateTime endTime,@Param("status") Integer completed);
}
